﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class operate_majorSet : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["student_id"] = "3120182109222";
        string[] keys = Request.QueryString.AllKeys;
        if (Request.QueryString[keys[0]] == "tb_major")
        {
            string sql = "select major_name from tb_major";
            System.Data.DataTable dt = SqlServer.GetDataTable(sql);
            //把表格转为字符串
            string strMajorSet = "";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strMajorSet = strMajorSet + dt.Rows[i][0].ToString() + ",";
            }
            strMajorSet = strMajorSet.Substring(0, strMajorSet.Length - 1);
            Response.Write(strMajorSet);
            Response.End();
        }
        if (Request.QueryString[keys[0]] == "tb_college")
        {
            string sql = "select college_id,college_name from tb_college";
            System.Data.DataTable dt = SqlServer.GetDataTable(sql);
            //把表格转为字符串
            string strMajorSet = "";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strMajorSet = strMajorSet + dt.Rows[i][0].ToString() +":"+ dt.Rows[i][1].ToString()+ ",";
            }
            strMajorSet = strMajorSet.Substring(0, strMajorSet.Length - 1);
            Response.Write(strMajorSet);
            Response.End();
        }
        if (Request.QueryString[keys[0]] == "tb_student")
        {
            string sql = "select  [student_id],[student_name] ,[student_tel] ,[major_name],[student_sex],[student_id_card],[student_photo_path] from tb_student inner join tb_major on tb_student.major_id =tb_major.major_id "
                +" where student_id ='"+Session["student_id"]+"'";
            System.Data.DataTable dt = SqlServer.GetDataTable(sql);
            //把表格转为字符串
            string strStudent = "";
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                strStudent = strStudent + dt.Rows[0][i].ToString() + ",";
            }
            strStudent = strStudent.Substring(0, strStudent.Length - 1);
            Response.Write(strStudent);
            Response.End();
        }
        if (Request.QueryString[keys[0]] == "tb_admin")
        {
            string sql = "select  [admin_id],[admin_name] ,[admin_tel]  from tb_admin  "
                + " where admin_id ='" + Session["admin_id"] + "'";
            System.Data.DataTable dt = SqlServer.GetDataTable(sql);
            //把表格转为字符串
            string strStudent = "";
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                strStudent = strStudent + dt.Rows[0][i].ToString() + ",";
            }
            strStudent = strStudent.Substring(0, strStudent.Length - 1);
            Response.Write(strStudent);
            Response.End();
        }
        if (Request.QueryString[keys[0]] == "tb_teacher")
        {
            string sql = "select  [teacher_id],[teacher_name] ,[teacher_tel]  from tb_teacher  "
                + " where teacher_id ='" + Session["teacher_id"] + "'";
            System.Data.DataTable dt = SqlServer.GetDataTable(sql);
            //把表格转为字符串
            string strStudent = "";
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                strStudent = strStudent + dt.Rows[0][i].ToString() + ",";
            }
            strStudent = strStudent.Substring(0, strStudent.Length - 1);
            Response.Write(strStudent);
            Response.End();
        }

    }
}